<style>
.xiadan_box1 input{ width:100%; border:0; margin-bottom:3px; color:#666}
.xiadan_box1 .xiadan_sp3{ border:0; width:100%; color:#666}
</style>
<script src="/statics/js/layer.js"></script>
<script class="resources library" src="/statics/js/area.js" type="text/javascript"></script>
<!-- 头部开始 -->
<div class="header">
<!--    <div class="header_r"><img src="img/tx.jpg" width="30"></div>-->
    <div class="header_l"><a href="javascript:history.back(-1)"></a></div>
    <div class="header_m">确认下单</div>
</div>
<!-- 头部结束 -->
    
<!--确认下单box1开始-->
<div class="xiadan-dz cd-popup-trigger">
    <a>
        <if condition="$dfaddress">
            <p><span></span><div id="putOn">&nbsp;&nbsp;{{$dfaddress['provice']}} {{$dfaddress['city']}} {{$dfaddress['area']}} {{$dfaddress['street']}}</div></p>
            <div class="xiadan-dz-bg"></div>
            <input type="hidden" id="receiveId" value="{{$dfaddress['address_id']}}" />
        <else/>
            <p><span></span><div id="putOn">请填写收货人地址</div></p>
            <div class="xiadan-dz-bg"></div>
            <input type="hidden" id="receiveId" value="" />
        </if>

    </a>

</div>
<!--确认下单bx1结束-->

<!--确认下单bx2开始-->



<div class="xiadan_box2">
    
    <?php if($params){$priceSum = 0;foreach(explode(',',$params) AS $km=>$vv){$goodsMsg = explode('_',$vv);$getGoodsMsg = M('GoodsEntity')->where(array('goods_id'=>$goodsMsg[0]))->find();?>
    <div class="xiadan_box2-box queren">
        <dl>
            <span><em>¥<?=$getGoodsMsg['goods_price']?></em><br />×<?=$goodsMsg[1]?><br /><i class="taxs">税费：￥<?=$getGoodsMsg['goods_taxes_price']*$goodsMsg[1]?></i></span>
            <dt><a href="/goods/detail/id/<?=$goodsMsg[0]?>/sek/<?=mySpreadSek($goodsMsg[2])?>"><img src="<?=transUrl($getGoodsMsg['goods_pic'])?>" width="50"></a></dt>
            <dd><a href="/goods/detail/id/<?=$goodsMsg[0]?>/sek/<?=mySpreadSek($goodsMsg[2])?>"><?=$getGoodsMsg['goods_title']?></a></dd>
            <dd class="xiadan_xh">规格：<?=$getGoodsMsg['goods_attr']?></dd>
        </dl>
        <div class="tax">据国家政策规定，本品适用于跨境综合税：<?=$getGoodsMsg['rate']*100?>%</div>
    </div>


    <!--<dl <?=$km+1 == count(explode(',',$params)) ? 'style="border-bottom:0px"' : '' ?>>-->
        <!--<span><em>¥<?=$getGoodsMsg['goods_price']?></em><br />×<?=$goodsMsg[1]?></span>-->
        <!--<dt><a href="/goods/detail/id/<?=$goodsMsg[0]?>/sek/<?=mySpreadSek($goodsMsg[2])?>"><img src="<?=transUrl($getGoodsMsg['goods_pic'])?>" width="50"></a></dt>-->
        <!--<dd><a href="/goods/detail/id/<?=$goodsMsg[0]?>/sek/<?=mySpreadSek($goodsMsg[2])?>"><?=$getGoodsMsg['goods_title']?></a></dd>-->
        <!--<dd class="xiadan_xh">规格：<?=$getGoodsMsg['goods_attr']?></dd>-->
    <!--</dl>-->
    <?php
        $priceSum += $getGoodsMsg['goods_price']*$goodsMsg[1];
        $taxesSum += $getGoodsMsg['goods_taxes_price']*$goodsMsg[1];
    }}?>
</div>
<!--确认下单bx2结束-->
<div class="tax-box">
    <p class="tax-box-o"><span>￥<?=$taxesSum?></span>税费</p >
</div>
<div class="freight" style="margin-bottom: 60px;">
	<p class="freight-o"><span>￥<if condition="$priceSum egt 99">0.00<else/>10.00<input type="hidden" value="10" id="express" /></if></span>运费</p>
	<p class="freight-t">注：满99元包邮</p>
</div>

<!--确认下单box3开始-->
<div class="xiadan_box3">
	<form action="/order/sendOrder" method="get" id="formIds">
		<input type="hidden" value="<?=I('get.params')?>" name="params" />
		<input type="hidden" value="" name="address_id" id="address_id" />
		<input type="hidden" value="" name="express" id="getexpress" />
	    <input type="hidden" value="<?=$taxesSum ?: 0?>" name="taxes" id="taxes" />
	    <input type="hidden" value="1" name="frFrom" />
    <p>实际应付：<em><if condition="$priceSum egt 99"><?=$priceSum+$taxesSum;?><else/><?=$priceSum+$taxesSum+10;?></if></em> 元<br />
        <i>含运费 : <if condition="$priceSum egt 99">0.00<else/>10.00</if> 税费：<?=$taxesSum?></i>
    </p >
    <button class="buxing" id="putSure">结算</button>
    </form>
</div>
<!--确认下单box3结束-->
    
    
<!--选择地址开始-->
<div class="cd-popup" role="alert">
    <div class="cd-popup-container">
        <div id="PopupLayer" class="PopupLayer"><a class="close cd-popup-close"></a>
            <p class="xd-dz">选择收货地址</p>
            <div class="xd-xzdz cd-popup-trigger2">
                <p><span></span>新增地址</p>
            </div>
            <?php if($getReceiveData){foreach($getReceiveData AS $vmx){?>
            <div class="xd-xzdz-ok">
                <p><a href="javascript:void(0)" class="setAddress" itv="<?=$vmx['address_id']?>"><?=$vmx['provice']?> <?=$vmx['city']?> <?=$vmx['area']?> <?=$vmx['street']?></a></p>
            </div>
            <?php }}?>
        </div>
    </div>
</div>
<!--选择地址结束-->
    
<!--新增地址开始-->
<div class="cd-popup2" role="alert">
    <div class="cd-popup-container2">
        <div id="PopupLayer2" class="PopupLayer2"><a class="close cd-popup-close2"></a>
            <p class="xd-dz">新增收货地址</p>
            <div class="xd-xzdz2"><span>姓　名：</span><input type="text" placeholder="姓名" class="needval" id="nameval"></div>
            <div class="xd-xzdz2"><span>身份证：</span><input type="text" placeholder="请输入真实身份证号码" class="needval" id="cardval"></div>
            <div class="xd-xzdz2 id-u"><span>身份证号码用于海关检查</span><em></em></div>
            <div class="xd-xzdz2"><span>电　话：</span><input type="text" placeholder="手机号" class="needval" id="mobileval"></div>
            <div class="xd-xzdz2"><span>地　区：</span>
                <div class="ldcs">
                    <select id="s_province" name="s_province" class="needval"></select>  
                    <select id="s_city" name="s_city" class="needval"></select>  
                    <select id="s_county" name="s_county" class="needval"></select>

                    <script type="text/javascript">_init_area();</script>
                </div>
            </div>
            <div class="xd-xzdz2"><span>地　址：</span><input type="text" placeholder="地址" class="needval" id="streetval"></div>
            <p class="canshu_n"><a href="javascript:void(0)" id="putAddressAdd">确定</a></p>
        </div>
    </div>
</div>
<!--新增地址结束-->

<script type="text/javascript">//点击增加、减少产品数量
function addOne() {
    var num = document.getElementById("num");
    num.value = parseInt(num.value) + 1;
}
function jianOne() {
    var num = document.getElementById("num");
    if ( num.value > 1){
        num.value = parseInt(num.value) - 1;
    }
    else{
        return false;
    }
}
</script>
    
<script type="text/javascript">
var Gid  = document.getElementById ;
var showArea = function(){
	Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" + 	
	Gid('s_city').value + " - 县/区" + 
	Gid('s_county').value + "</h3>"
							}
Gid('s_county').setAttribute('onchange','showArea()');
</script>
<script>
$(function(){
	$('#putSure').click(function(){
        if($('#receiveId').val()){
        	$('#address_id').val($('#receiveId').val());
        	$('#getexpress').val($('#express').val());
        	$('#formIds').submit();
        }else{
            layer.msg('收货地址不能为空', {icon: 0});return false;
        }
	});
	$('.setAddress').click(function(){
		$('#putOn').html('&nbsp;&nbsp;'+$(this).html());
		$('#receiveId').val($(this).attr('itv'));
		$('.cd-popup-close').click();
	});
	$('#putAddressAdd').click(function(){
		mcontinue = 1;
		$('.needval').each(function(){
			if(!$(this).val()){
				layer.msg($(this).attr('placeholder')+' 项不能为空', {icon: 0});
				mcontinue = 0;
			}else{
				if (!$("#mobileval").val().match(/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(14[0-9]{1})|(17[0-9]{1}))+\d{8})$/)) {
				layer.msg('手机号码有误', {icon: 0});
				mcontinue = 0;return false; 
			} 
			}
			
		});
		if(mcontinue > 0){
			setTimeout(function(){
				$.post('/order/addAddress',{'dosubmit':'1','name':$('#nameval').val(),'identity':$('#cardval').val(),'mobile':$('#mobileval').val(),'provice':$('#s_province').val(),'city':$('#s_city').val(),'area':$('#s_county').val(),'street':$('#streetval').val()},function(data){
					if(data.code == '1'){
						window.location.reload();
					}else{
						alert(data.msg);
					}
				},'json');
			},1000);
		}
	});
})
</script>
<script type="text/javascript">
    $(document).ready(function(){
        $('.taxs').click(function(){
            var tax1 = $(this).attr("class");
            if(tax1=='taxs'){
                $(this).parents('.xiadan_box2-box').find('.tax').slideToggle();
                $(this).removeClass('taxs').addClass('taxs2')
            }else{
                $(this).parents('.xiadan_box2-box').find('.tax').slideToggle();
                $(this).removeClass('taxs2').addClass('taxs')
            }
        })
    })
</script>